const http = require('../../utils/http')

Page({
	data: {
		detail: {}
	},
	onLoad: function (options) {
		let id = options.id || 14
		this.getActivity(id)
	},
	
	formatRichText(html) {
		let newContent = html.replace(/\<img/gi, '<img class="richImg"');
		return newContent;
	},
	getActivity(id) {
		http.request({
			url: '/activityRecord/getActivity',
			method: 'GET',
			data: {id},
			callBack: (res) => {
				if (res) {
					
					res.content=this.formatRichText(res.content)
					console.log(res.content)
					res.fee = parseFloat(res.fee / 100).toFixed(2)
					this.setData({
						detail: res
					})
				} else {
					wx.showToast({
						icon: 'none',
						title: '未查询到活动信息'
					})
				}
			}
		})
	},
	toJoinActivity() {
		wx.setStorage({
			key: 'activity',
			data: this.data.detail,
			success: (res) => {
				wx.navigateTo({
					url: '/pages/createActivityOrder/index'
				})
			}
		})
		
	}
});